<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/common/common.jsp" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> 
  <head>
    <base href="<%=basePath%>" />
    <title>Allocator Data Information Management</title>
    <script type="text/javascript">
		var path = "<%=basePath%>";
		//分配表数据的上传任务批次
		var batchConcentratorNo = "<s:property escape='false' value='concentratorNo' />";
		var batchRecordTime = "<s:date name='recordTime' format='yyyy-MM-dd' nice='false' />";
	</script>
	<meta http-equiv="pragma" content="no-cache" />
	<meta http-equiv="cache-control" content="no-cache" />
	<meta http-equiv="expires" content="0" />    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3" />
	<meta http-equiv="description" content="This is my page" />
	<link rel="stylesheet" type="text/css" href="<%=basePath%>beshs/css/content.css" />
	<script type="text/javascript" src="<%=basePath%>resources/jquery/jquery-1.7.2.min.js"></script>
	<!-- JS通用工具 -->
	<jsp:include page="/resources/resource-refer/common-validator-reference.jsp" />
	<!-- 系统通用资源 -->
	<jsp:include page="/resources/resource-refer/common-resource-reference.jsp" />
	<!-- EasyUI资源 -->
	<jsp:include page="/resources/resource-refer/component-easyui-reference.jsp" />
	<!-- 表单校验 -->
	<jsp:include page="/resources/resource-refer/component-validform-reference.jsp" />
	<!-- 用户访问菜单路径 -->
	<jsp:include page="/resources/usertrace/common-uservisit-reference.jsp" />
  </head>
  <script type="text/javascript">
  	function formVerify() {
  		var verify = true;
  		//读数对应时间
  		var readTime = $("input[name='readTime']").val();
  		if(!isChinaDateTime($.trim(readTime))) { 
  			$("span#span_readTime").empty().append("<img src='"+path+"beshs/images/wrong.gif' />");
  			verify = false;
  		} else {
  			$("span#span_readTime").empty().append("<img src='"+path+"beshs/images/right.gif' />");
  		}
  		//抄表时间
  		var recordTime = $("input[name='recordTime']").val();
  		if(!isChinaDateTime($.trim(recordTime))) { 
  			$("span#span_recordTime").empty().append("<img src='"+path+"beshs/images/wrong.gif' />");
  			verify = false;
  		} else {
  			$("span#span_recordTime").empty().append("<img src='"+path+"beshs/images/right.gif' />");
  		}
  		return verify;
  	}
  
  	function submitForm() {
  		var meterDataUID = "<s:property value='meterDataUID' />";
  		//表单信息
  		var concentratorNo = $("input[name='concentratorNo']").val(); //集中器号
  		var seriousNum = $("input[name='seriousNum']").val(); //分配表号
  		//读数
  		var readNum = $("input[name='readNum']").val();
  		//读数对应时间
  		var readTime = $("input[name='readTime']").val();
  		//背板温度
  		var backTmperature = $("input[name='backTmperature']").val();
  		//前板温度
  		var fontTemperature = $("input[name='fontTemperature']").val();
  		//抄表时间
  		var recordTime = $("input[name='recordTime']").val();
  		//去年热量
  		var lastYearHeat = $("input[name='lastYearHeat']").val();
  		//1month heat
  		var oneHeat = $("input[name='oneHeat']").val();
  		//2month heat
  		var twoHeat = $("input[name='twoHeat']").val();
  		//3month heat
  		var threeHeat = $("input[name='threeHeat']").val();	
  		//4month heat
  		var fourHeat = $("input[name='fourHeat']").val();
  		//5month heat
  		var fiveHeat = $("input[name='fiveHeat']").val();
  		//6month heat
  		var sixHeat = $("input[name='sixHeat']").val();
  		//7month heat
  		var sevenHeat = $("input[name='sevenHeat']").val();
  		//8month heat
  		var eightHeat = $("input[name='eightHeat']").val();
  		//9month heat
  		var nineHeat = $("input[name='nineHeat']").val();
  		//10month heat
  		var tenHeat = $("input[name='tenHeat']").val();
  		//11month heat
  		var elevenHeat = $("input[name='elevenHeat']").val();
  		//12month heat
  		var twelveHeat = $("input[name='twelveHeat']").val();
  		//备注
  		var remark = $("textarea[name='remark']").val();
  		$.getJSON(path+"beshs/assignMeterDataGatherActionJson!saveOrUpdateMeterData.do?date="+new Date(), {
  			"meterData.concentratorNo": concentratorNo, //集中器号
  			"meterData.seriousNum": seriousNum, //分配表号
  			"meterData.id": meterDataUID,
  			"meterData.readNum": readNum,
  			"meterData.readTime": readTime,
  			"meterData.backTmperature": backTmperature,
  			"meterData.fontTemperature": fontTemperature,
  			"meterData.recordTime": recordTime,
  			"meterData.lastYearHeat": lastYearHeat,
  			"meterData.oneHeat": oneHeat,
  			"meterData.twoHeat": twoHeat,
  			"meterData.threeHeat": threeHeat,
  			"meterData.fourHeat": fourHeat,
  			"meterData.fiveHeat": fiveHeat,
  			"meterData.sixHeat": sixHeat,
  			"meterData.sevenHeat": sevenHeat,
  			"meterData.eightHeat": eightHeat,
  			"meterData.nineHeat": nineHeat,
  			"meterData.tenHeat": tenHeat,
  			"meterData.elevenHeat": elevenHeat,
  			"meterData.twelveHeat": twelveHeat,
  			"meterData.remark": remark
  		}, function(data){
  			if(data.success) {
  				Dialog.alert("Successful Operation！", function() {
  					var dataUploadType = "<s:property value='dataUploadType' />";
  					var index = parent.layer.getFrameIndex(window.name)
  					if(dataUploadType == "txtUpload") { //TXT上传
  						//TXT上传的分配表数据
  						var dataFileUID = "<s:property value='dataFileUID' />";
  						parent.window.frames["meterDataPage"].location = path + "beshs/assignMeterDataGatherAction!queryMeterDataPageByFileID.do?dataFileUID="+dataFileUID
	  							+"&date="+new Date();
  					} else if(dataUploadType == "batchUpload") { //GPRS批量上传
  						parent.window.frames["meterDataPage"].location = path + "beshs/assignMeterDataGatherAction!queryMeterDataPageByUploadBatch.do?concentratorNo="+encodeURIComponent(batchConcentratorNo)
								+"&recordTime="+batchRecordTime
								+"&date="+new Date();
  						parent.window.frames["questionDataPage"].location = path + "beshs/assignMeterDataGatherAction!queryNonRationalMeterDataList.do?concentratorNo="+encodeURIComponent(batchConcentratorNo)
								+"&recordTime="+batchRecordTime
								+"&date="+new Date();
  					}
  					parent.layer.close(index);
  				});
  			} else {
  				Dialog.alert(data.msg);
  			}
  		});
  	}
  	
  	$(function(){
		$("form[name='assignMeterDataForm']").Validform({
			btnSubmit: "input[name='submit']",
			btnReset: "input[name='reset']",
			tiptype: function(msg, o, cssctl){
				//msg：提示信息;
				//o:{obj:*,type:*,curform:*}, obj指向的是当前验证的表单元素（或表单对象），type指示提示的状态，值为1、2、3、4， 1：正在检测/提交数据，2：通过验证，3：验证失败，4：提示ignore状态, curform为当前form对象;
				//cssctl:内置的提示信息样式控制函数，该函数需传入两个参数：显示提示信息的对象 和 当前提示的状态（既形参o中的type）;
				if(!o.obj.is("form")){//验证表单元素时o.obj为该表单元素，全部验证通过提交表单时o.obj为该表单对象;
					var objtip=o.obj.siblings(".Validform_checktip");
					cssctl(objtip,o.type);
					objtip.text(msg);
				} else {
					var objtip=o.obj.find("#msgdemo");
					cssctl(objtip,o.type);
					objtip.text(msg);
				}
			},
			postonce: true, //开启二次提交防御，在数据成功提交后，表单将不能再继续提交
			showAllError: true, //提交表单时所有错误提示信息都会显示
			ajaxPost:true,
			beforeSubmit: function(curform) { //在验证成功后，表单提交前执行的函数，curform参数是当前表单对象
				var additionalVerify = formVerify();
				if(additionalVerify) {
					submitForm();
				}
				return true; //这里明确return false的话表单将不会提交
			}
		});
  	});
  </script>
  <body>
    <div class="content_all">
  		<!--导航条-->
  		<div class="insertinfo_table">
      		<form action="#" name="assignMeterDataForm"><table width="100%" border="0" cellspacing="0" cellpadding="0">
      			<tr>
      				<th>Concentrator No.：</th>
      				<td>
      					<s:if test="meterData.id!=null && !''.equals(meterData.id)">
      						<input name="concentratorNo" type="text" class="s_input" value="<s:property escape='false' value='meterData.concentratorNo' />" disabled="disabled" />
      					</s:if>
      					<s:else>
      						<input name="concentratorNo" type="text" class="s_input" value="<s:property escape='false' value='concentratorNo' />" disabled="disabled" />
      					</s:else>
      				</td>
      				<th>Allocator No.：</th>
      				<td><input name="seriousNum" type="text" class="s_input" value="<s:property escape='false' value='meterData.seriousNum' />" 
      						datatype="/^[0-9a-zA-Z]{1,40}$/" sucmsg="Allocator No. Verification Passed！" nullmsg="Please enter Allocator No.！" errormsg="Allocator No. only can be composed of letters,numbers and dashes within 1~40 characters！"/>
      					&nbsp;<span style="color:#FF0000;">*</span>
      					<div class="Validform_checktip">Allocator No. only can be composed of letters,numbers and dashes within 1~40 characters！</div></td>
      			</tr>
        		<tr>
          			<th>Readings：</th>
          			<td><input name="readNum" type="text" class="s_input" value="<s:property value='meterData.readNum' />" 
          					datatype="n1-10|/^([1-9]\d*\.\d*|0\.\d*[1-9]\d*|0?\.0+|0)$/" sucmsg="Readings Verification Passed！" nullmsg="Please enter readings！" errormsg="Please enter integral or float type value！"/>
            			&nbsp;<span style="color:#FF0000;">*</span>
            			<div class="Validform_checktip">Please enter integral or float type value！</div></td>
            		<th>Upload Time：</th>
          			<td>
          			<input id="" name="readTime" class="Wdate" value="<s:date name='readTime' format='yyyy-MM-dd HH:mm:ss' nice='false' />" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',readOnly:true})" />
          			
<!--         				<input name="readTime"  class="easyui-datetimebox" type="text"  -->
<%--         						value="<s:date name='meterData.readTime' format='yyyy-MM-dd HH:mm:ss' nice='false' />" readOnly/> --%>
        				&nbsp;<span style="color:#FF0000;" id="span_readTime">*</span>
        				<div class="Validform_checktip">Please enter date and time in correct format such as-- 2014-07-30 15:52:00！</div></td>
        		</tr>
        		<tr>
          			<th>Rear Board Temperature：</th>
          			<td><input name="backTmperature" type="text" class="s_input" value="<s:property value='meterData.backTmperature' />" 
          					datatype="n1-10|/^([1-9]\d*\.\d*|0\.\d*[1-9]\d*|0?\.0+|0)$/" sucmsg="Rear Board Temperature Verification Passed！" nullmsg="Please enter rear board temperature！" errormsg="Please enter integral or float type value！"/>
            			&nbsp;&#8451;<span style="color:#FF0000;">*</span>
            			<div class="Validform_checktip">Please enter integral or float type value！</div></td>
            		<th>Front Board Temperature：</th>
          			<td><input name="fontTemperature" type="text" class="s_input" value="<s:property value='meterData.fontTemperature' />" 
          					datatype="n1-10|/^([1-9]\d*\.\d*|0\.\d*[1-9]\d*|0?\.0+|0)$/" sucmsg="Front Board Temperature Verification Passed！" nullmsg="Please enter front board temperature！" errormsg="Please enter integral or float type value！"/>
            			&nbsp;&#8451;<span style="color:#FF0000;">*</span>
            			<div class="Validform_checktip">Please enter integral or float type value！</div></td>
        		</tr>
        		<tr>
          			<th>Meter Reading Time：</th>
        			<s:if test="meterData != null">
        			<input id="" name="recordTime" class="Wdate" value="<s:date name='recordTime' format='yyyy-MM-dd HH:mm:ss' nice='false' />" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',readOnly:true})" />
        				
<!--         				<td><input name="recordTime"  class="easyui-datetimebox" type="text"  -->
<%--         					value="<s:date name='meterData.recordTime' format='yyyy-MM-dd HH:mm:ss' nice='false' />" readOnly/> --%>
        				&nbsp;<span style="color:#FF0000;" id="span_recordTime">*</span>
        				<div class="Validform_checktip">Please enter date and time in correct format such as-- 2014-07-30 15:52:00！</div></td>
        			</s:if>
        			<s:else>
        				<td><input name="recordTime"  class="easyui-datetimebox" type="text" 
        					value="<s:date name='recordTime' format='yyyy-MM-dd HH:mm:ss' nice='false' />" readOnly/>
        				&nbsp;<span style="color:#FF0000;" id="span_recordTime">*</span>
        				<div class="Validform_checktip">Please enter date and time in correct format such as-- 2014-07-30 15:52:00！</div></td>
        			</s:else>
        			<th>Last Year Heat：</th>
          			<td><input name="lastYearHeat" type="text" class="s_input" value="<s:property value='meterData.lastYearHeat' />" 
          					datatype="n1-10|/^([1-9]\d*\.\d*|0\.\d*[1-9]\d*|0?\.0+|0)$/" ignore="ignore" errormsg="Please enter integral or float type value！"/>
            			&nbsp;<span style="color:#FF0000;"></span>
            			<div class="Validform_checktip"></div></td>
        		</tr>
        		<tr>
          			<th>1month heat：</th>
          			<td><input name="oneHeat" type="text" class="s_input" value="<s:property value='meterData.oneHeat' />" 
          					datatype="n1-10|/^([1-9]\d*\.\d*|0\.\d*[1-9]\d*|0?\.0+|0)$/" ignore="ignore" errormsg="Please enter integral or float type value！"/>
            			&nbsp;<span style="color:#FF0000;"></span>
            			<div class="Validform_checktip"></div></td>
            		<th>2month heat：</th>
          			<td><input name="twoHeat" type="text" class="s_input" value="<s:property value='meterData.twoHeat' />" 
          					datatype="n1-10|/^([1-9]\d*\.\d*|0\.\d*[1-9]\d*|0?\.0+|0)$/" ignore="ignore" errormsg="Please enter integral or float type value！"/>
            			&nbsp;<span style="color:#FF0000;"></span>
            			<div class="Validform_checktip"></div></td>
        		</tr>
        		<tr>
          			<th>3month heat：</th>
          			<td><input name="threeHeat" type="text" class="s_input" value="<s:property value='meterData.threeHeat' />" 
          					datatype="n1-10|/^([1-9]\d*\.\d*|0\.\d*[1-9]\d*|0?\.0+|0)$/" ignore="ignore" errormsg="Please enter integral or float type value！"/>
            			&nbsp;<span style="color:#FF0000;"></span>
            			<div class="Validform_checktip"></div></td>
            		<th>4month heat：</th>
          			<td><input name="fourHeat" type="text" class="s_input" value="<s:property value='meterData.fourHeat' />" 
          					datatype="n1-10|/^([1-9]\d*\.\d*|0\.\d*[1-9]\d*|0?\.0+|0)$/" ignore="ignore" errormsg="Please enter integral or float type value！"/>
            			&nbsp;<span style="color:#FF0000;"></span>
            			<div class="Validform_checktip"></div></td>
        		</tr>
        		<tr>
          			<th>5month heat：</th>
          			<td><input name="fiveHeat" type="text" class="s_input" value="<s:property value='meterData.fiveHeat' />" 
          					datatype="n1-10|/^([1-9]\d*\.\d*|0\.\d*[1-9]\d*|0?\.0+|0)$/" ignore="ignore" errormsg="Please enter integral or float type value！"/>
            			&nbsp;<span style="color:#FF0000;"></span>
            			<div class="Validform_checktip"></div></td>
            		<th>6month heat：</th>
          			<td><input name="sixHeat" type="text" class="s_input" value="<s:property value='meterData.sixHeat' />" 
          					datatype="n1-10|/^([1-9]\d*\.\d*|0\.\d*[1-9]\d*|0?\.0+|0)$/" ignore="ignore" errormsg="Please enter integral or float type value！"/>
            			&nbsp;<span style="color:#FF0000;"></span>
            			<div class="Validform_checktip"></div></td>
        		</tr>
        		<tr>
          			<th>7month heat：</th>
          			<td><input name="sevenHeat" type="text" class="s_input" value="<s:property value='meterData.sevenHeat' />" 
          					datatype="n1-10|/^([1-9]\d*\.\d*|0\.\d*[1-9]\d*|0?\.0+|0)$/" ignore="ignore" errormsg="Please enter integral or float type value！"/>
            			&nbsp;<span style="color:#FF0000;"></span>
            			<div class="Validform_checktip"></div></td>
            		<th>8month heat：</th>
          			<td><input name="eightHeat" type="text" class="s_input" value="<s:property value='meterData.eightHeat' />" 
          					datatype="n1-10|/^([1-9]\d*\.\d*|0\.\d*[1-9]\d*|0?\.0+|0)$/" ignore="ignore" errormsg="Please enter integral or float type value！"/>
            			&nbsp;<span style="color:#FF0000;"></span>
            			<div class="Validform_checktip"></div></td>
        		</tr>
        		<tr>
          			<th>9month heat：</th>
          			<td><input name="nineHeat" type="text" class="s_input" value="<s:property value='meterData.nineHeat' />" 
          					datatype="n1-10|/^([1-9]\d*\.\d*|0\.\d*[1-9]\d*|0?\.0+|0)$/" ignore="ignore" errormsg="Please enter integral or float type value！"/>
            			&nbsp;<span style="color:#FF0000;"></span>
            			<div class="Validform_checktip"></div></td>
            		<th>10month heat：</th>
          			<td><input name="tenHeat" type="text" class="s_input" value="<s:property value='meterData.tenHeat' />" 
          					datatype="n1-10|/^([1-9]\d*\.\d*|0\.\d*[1-9]\d*|0?\.0+|0)$/" ignore="ignore" errormsg="Please enter integral or float type value！"/>
            			&nbsp;<span style="color:#FF0000;"></span>
            			<div class="Validform_checktip"></div></td>
        		</tr>
        		<tr>
          			<th>11month heat：</th>
          			<td><input name="elevenHeat" type="text" class="s_input" value="<s:property value='meterData.elevenHeat' />" 
          					datatype="n1-10|/^([1-9]\d*\.\d*|0\.\d*[1-9]\d*|0?\.0+|0)$/" ignore="ignore" errormsg="Please enter integral or float type value！"/>
            			&nbsp;<span style="color:#FF0000;"></span>
            			<div class="Validform_checktip"></div></td>
            		<th>12month heat：</th>
          			<td><input name="twelveHeat" type="text" class="s_input" value="<s:property value='meterData.twelveHeat' />" 
          					datatype="n1-10|/^([1-9]\d*\.\d*|0\.\d*[1-9]\d*|0?\.0+|0)$/" ignore="ignore" errormsg="Please enter integral or float type value！"/>
            			&nbsp;<span style="color:#FF0000;"></span>
            			<div class="Validform_checktip"></div></td>
        		</tr>
        		<tr>
        			<th>Remark：</th>
          			<td colspan="3">
          				<textarea name="heatSinker.remark" cols="45" rows="3"
          					datatype="*1-200" ignore="ignore" errormsg="Invalid input!  please input valid content ,no more than 200pcs character">
          					<s:property value='heatSinker.remark' /></textarea>
          				<div class="Validform_checktip"></div></td>
        		</tr>
        		<tr>
          			<td style="border:none;" colspan="4" align="center">
          				<input name="submit" type="button" value="Submit" class="s_btn" />
            			<input name="reset" type="reset" value="Reset" class="s_btn"/></td>
        		</tr>
      		</table></form>
  		</div>
	</div>
	<div class="clear"></div>
  </body>
</html>
